package com.example.controller;

import com.example.common.Result;
import com.example.exception.CustomException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class WebController {
  @GetMapping("/hello")
  public String hello() {
    return "Hello World!";
  }

  @GetMapping("/count")
  public Result count() {
    throw new CustomException("400", "自定义异常");
  }

  @GetMapping("/map")
  public Result map() {
    HashMap<String, Object> map = new HashMap<>();
    map.put("name", "张三");
    map.put("age", 18);
    return Result.success(map);
  }
}
